import scrapy


class TicketSpider(scrapy.Spider):
    name = 'ticket'
    allowed_domains = ['qunar.com']
    start_urls = ['https://piao.qunar.com/']

    def parse(self, response):
        # 首页xpath 省市url
        div_country_list = response.xpath("//div[@class='mp-city-country']/div[@class='mp-city-area']")
        for div in div_country_list:
            ticket = {}
            ticket["location"] = div.xpath("./h6/text()").extract_first()
            ticket["province"] = div.xpath(".//div[@class='mp-city-list-province']/a/text()").extract_first()
            city_list = div.xpath("")
        pass

    # list https://piao.qunar.com/ticket/list.json?from=mps_search_suggest_h&keyword=%E6%B7%B1%E5%9C%B3&page=1
    # list https://piao.qunar.com/ticket/list.json?from=mps_search_suggest_h&keyword=%E6%B7%B1%E5%9C%B3&page=2
    # detail "https://piao.qunar.com/ticket/detail_{}.html".format(sightId)

    # comment https://piao.qunar.com/ticket/detailLight/sightCommentList.json?sightId=191026&index=1&page=1&pageSize=10&tagType=0
    #         https://piao.qunar.com/ticket/detailLight/sightCommentList.json?sightId=191026&index=2&page=2&pageSize=10&tagType=0
    #         https://piao.qunar.com/ticket/detailLight/sightCommentList.json?sightId=191026&index=3&page=3&pageSize=10&tagType=0

    # 一日游  https://piao.qunar.com/ticket/detail/getTickets.json

